﻿using KayakMes.Check.Application;
using KayakMes.Check.Application.Input;
using KayakMes.Check.Domain;
using KayakMes.Common.Dtos.CheckDto;
using KayakMes.Common.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace KayakMes.Check.API.Controllers
{
    /// <summary>
    /// 检测标准模块
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CheckWayController : ControllerBase
    {
        private readonly ICheckService _checkService;

        public CheckWayController(ICheckService checkService)
        {
            _checkService = checkService;
        }

        /// <summary>
        /// 添加检查方式
        /// </summary>
        /// <param name="checkWay"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 

        [HttpPost]
        public ApiResult< int> AddCheckWay(AddCheckWayInput checkWay)
        {
            return _checkService.AddCheckWay(checkWay);
        }
        /// <summary>
        /// 获取单条检查方式
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiResult< CheckWayModel> CheckWayModel(long Id)
        {
            return _checkService.CheckWayModel(Id);
        }
        /// <summary>
        /// 删除检查方式
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 

        [HttpGet]
        public ApiResult< int> DeleteCheckWay(long Id)
        {
           return _checkService.DeleteCheckWay(Id);
        }
        /// <summary>
        /// 分页所有检查方式
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiPaging<CheckWayDto> GetAllCheckWay([FromQuery]CheckWayInput input)
        {
          return _checkService.GetAllCheckWay(input);
        }
        /// <summary>
        /// 修改检查方式
        /// </summary>
        /// <param name="checkWay"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpPost]
        public ApiResult< int> UpdateCheckWay(UpdateCheckWayInput checkWay)
        {
           return _checkService.UpdateCheckWay(checkWay);
        }

        /// <summary>
        /// 生成新的检验编码
        /// </summary>
        /// <returns>返回新生成的检验编码</returns>
        [HttpGet]
        public string GenerateCheckCode()
        {
            return _checkService.GenerateCheckCode();
        }
    }
}
